//
//  StatusCellBottomView.swift
//  sina
//
//  Created by 江先铨 on 15/11/16.
//  Copyright © 2015年 jxqstatic. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    
    @objc private func retweetedBtnClickBtn() {
    
       let  temp = retweetedController()
      //跳转控制器
      retweetedBtn.NavController()?.pushViewController(temp, animated: true)
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        //设置底部的背景颜色为0.95 
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func setupUI() {
         addSubview(retweetedBtn)
         addSubview(composeBtn)
         addSubview(likeBtn)
        
        retweetedBtn.addTarget(self, action: "retweetedBtnClickBtn", forControlEvents: .TouchUpInside)
        
        let w: CGFloat = 0.5
        let scale = 0.4
        //设置按钮的约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(snp_left)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
        }
        
        
        let sepView1 = sepView()
        addSubview(sepView1)
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(scale) //体积为0.4倍
            make.centerY.equalTo(self.snp_centerY)  //设置横线的中心为底部view 的中心
            make.width.equalTo(w) //宽度为0.5
        }
        
        
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.top.equalTo(snp_top)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        
        let sepView2 = sepView()
        addSubview(sepView2)
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.height.equalTo(composeBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        //赞的约束
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.top.equalTo(snp_top)
            make.right.equalTo(snp_right) //设置赞的右边的约束 看他们的约束为多少
            make.height.equalTo(snp_height)
            make.width.equalTo(composeBtn.snp_width)
        }
    }
    //创建分割线
    private func sepView() -> UIView {
    
      let v = UIView()
      v.backgroundColor = UIColor.darkGrayColor()
      return  v
    }
    
    //加载转发按钮
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(),image: "timeline_icon_retweet",size: 10)
    //加载评论按钮
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    //加载赞按钮
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)
    
}

